//
//  LCBaseVC.m
//  LongChain
//
//  Created by FengZi on 2018/3/14.
//  Copyright © 2018年 FengZi. All rights reserved.
//

#import "LCBaseVC.h"

@interface LCBaseVC ()

@end

@implementation LCBaseVC

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self customNavigationBar];

}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _showLeftBarButtonItem = YES;

    [self setNeedsStatusBarAppearanceUpdate];
    

    if (@available(iOS 11.0, *)) {
        [UIScrollView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

    }else{
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    
}
- (void)customNavigationBar {
    
    UIImage *image = [UIImage imageNamed:@"navBg"];
    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [UIImage new];

    if (self.navigationController.viewControllers.count > 1) {
        UIBarButtonItem *leftBackItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"home_ic_back_n"] style:UIBarButtonItemStyleDone target:self action:@selector(popToBack)];
        leftBackItem.tintColor = [UIColor whiteColor];
        self.navigationItem.leftBarButtonItem = leftBackItem;
    }
    
    UINavigationBar *navigationBar = [UINavigationBar appearance];
    navigationBar.backIndicatorImage = [UIImage imageNamed:@"home_ic_back_n"];
    [navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    navigationBar.shadowImage = [UIImage new];

    
}

- (void)customTranslucentNavigationBar {
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [UIImage new];

}
- (void)popToBack {
    [self.navigationController popViewControllerAnimated:YES];
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    
    return UIStatusBarStyleLightContent;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
